package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.CustomerReturnList;
import com.atguigu.jxc.entity.SaleList;
import com.atguigu.jxc.service.CustomerReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/customerReturnListGoods")
public class CustomerReturnController {
    @Autowired
    private CustomerReturnService customerReturnService;
    //http://localhost:8080/returnListGoods/save?returnNumber=TH1605768591211
    //退货单保存
    @PostMapping("/save")
    public ServiceVO save(CustomerReturnList customerReturnList, String customerReturnListGoodsStr){
        this.customerReturnService.saveReturnList(customerReturnList,customerReturnListGoodsStr);
        return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
    }
    @PostMapping("/list")
    public Map<String,Object> list(String returnNumber, Integer customerId, Integer state, String sTime, String eTime){
        return customerReturnService.getReturnList(returnNumber,customerId,state,sTime,eTime);
    }
    @PostMapping("/goodsList")
    public Map<Object, Object> goodsList(Integer customerReturnListId){
        return customerReturnService.getReturnListGoods(customerReturnListId);
    }
    //删除退货单
    @PostMapping("/delete")
    public ServiceVO delete(Integer customerReturnListId) {
        this.customerReturnService.returnDelete(customerReturnListId);
        return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
    }
    @PostMapping("/count")
    public List<CustomerReturnList> getCusReturnCount(String sTime, String eTime , Integer goodsTypeId, String codeOrName){
        return customerReturnService.getCusReturnCount(sTime,eTime,goodsTypeId,codeOrName);
    }
}
